package jee.boot.common.basic;

/**
 * Service层公用的Exception, 从由Spring管理事务的函数中抛出时会触发事务回滚.
 *
 * @author zhilei.wang
 */
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private Integer code = 500;//异常代码,默认500错误
    private Object data;//异常数据

    public ServiceException() {
    }

    public ServiceException(String message) {
        super(message);
    }

    public ServiceException(Throwable cause) {
        super(cause);
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    public ServiceException(String message, Throwable cause, Object data) {
        super(message, cause);
        this.data = data;
    }

    public ServiceException(Integer code) {
        super("MessageCode:" + code);
        this.code = code;
    }

    public ServiceException(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public ServiceException(Integer code, String message, Object data) {
        super(message);
        this.code = code;
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
